/**
 * Copyright(c) kyle.
 */
package com.kyle.redpacket.controller;

import com.kyle.redpacket.dto.result.Result;
import com.kyle.redpacket.dto.result.ResultException;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * 处理器增强
 *
 * @author kyle
 * @version 1.00.00
 * @since: [2021-01-11 20:52]
 * @updateUser: [Kyle]
 * @updateRemark: [说明本次修改内容]
 * @date: [2021-01-11 20:52]
 */
@RestControllerAdvice
public class MyControllerAdvice {

    @ExceptionHandler(Exception.class)
    @ResponseStatus(code = HttpStatus.INTERNAL_SERVER_ERROR)
    public Result<?> handOut(Exception e) {
        return Result.isFail(e.getMessage());
    }

    @ExceptionHandler(ResultException.class)
    @ResponseStatus(code = HttpStatus.INTERNAL_SERVER_ERROR)
    public Result<?> handOutx(ResultException e) {
        return Result.isFail(e.getResultEnum());
    }
}
